var util = require('../../utils/common.js'); //引入公共JS 


import { ChangeApply } from 'changeApply.model.js';
var changeApply = new ChangeApply();
Page({
  data: {
    showIcon: true,
    //显示返回键以及首页
    idSelect: true,
    showMessage: false,
    changeText: "请选择改签原因"
  },
  onLoad: function (options) {
    var oid = options.oid;
    var vendorOrderId = options.vendorOrderId;
    this.setData({
      oid: oid,
      vendorOrderId: vendorOrderId
    });
  },
  changeOpen: function () {
    //点击查看列车时刻表
    this.setData({
      idSelect: false
    });
  },
  changeClose: function () {
    //点击查看列车时刻表
    this.setData({
      idSelect: true
    });
  },
  idSelect: function (e) {
    this.setData({
      changeText: e.currentTarget.dataset.text,
      idSelect: true
    });
  },
  //确认改签
  changeSubmit: function (e) {
    console.log(e);
    var oid = e.target.dataset.oid;
    var vendororderid = e.target.dataset.vendororderid;

    if (this.data.changeText == "请选择改签原因") {
      this.showMessage('请选择改签原因');
    }

    changeApply.endorse(res => {
      console.log(res);
    });
  },
  showMessage: function (text) {
    var that = this;
    that.setData({
      showMessage: true,
      messageContent: text
    });
    setTimeout(function () {
      that.setData({
        showMessage: false,
        messageContent: ''
      });
    }, 3000);
  }
});